<div ng-controller="RoleCtrl" ng-init="addAction()" class="sui-form form-horizontal">
    <form name="itemForm" novalidate ng-submit="saveData()">
        <ul class="sui-breadcrumb">
            <li><a href="#/role/list">{{'Roles'|translate}}</a></li>
            <li class="active">{{item.role_id?'edit':'add_new' | translate}}</li>
        </ul>
        <div class="control-group" ng-show="item.role_id">
            <label class="control-label v-top">{{'Rolesid'|translate}}:</label>
            <div class="controls">
                {{item.role_id}}
            </div>
        </div>
        <div class="control-group">
            <label class="control-label v-top"><b style="color: #f00;">*</b> {{'Name'|translate}} :</label>
            <div class="controls">
                <input ng-model="item.name" name="name" type="text" value="" class="input-xlarge" required>
                <div ng-show="itemForm.name.$error.required" class="sui-msg msg-error msg-clear help-block error">
                    <div class="msg-con">{{'required'| translate}}</div>
                    <s class="msg-icon"></s>
                </div>
            </div>
        </div>
        <div class="control-group" ng-show="false">
            <label class="control-label v-top"><b style="color: #f00;">*</b> {{'is_super_admin'|translate}} :</label>
            <div class="controls">
                <select ng-model="item.is_super_admin" class="input-xlarge" name="is_super_admin">
                    <option value="false">{{'no'| translate}}</option>
                    <option value="true">{{'yes'| translate}}</option>
                </select>
                <div ng-show="itemForm.is_super_admin.$dirty && itemForm.is_super_admin.$invalid" class="sui-msg msg-error msg-clear help-block error">
                    <div class="msg-con">{{'required'| translate}}</div>
                    <s class="msg-icon"></s>
                </div>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label v-top"> {{'是否是管理员' | translate}} :</label>
            <div class="controls">
                <choice ng-model="item.is_super_admin" dft="1"></choice>
            </div>
        </div>
        <div class="control-group" ng-show="!item.is_super_admin">
            <label class="control-label v-top"><b style="color: #f00;">*</b> {{'资源'|translate}} :</label>
            <div class="controls">
                <role-type-tab ng-model="chosedType" style="width: 350px"></role-type-tab>
                <div class="controls" ng-show="chosedType == 1 ">
                    <wx-app-checkbox ng-model="istores"></wx-app-checkbox>{{store}}
                </div>
                <div class="controls" ng-show="chosedType == 2 ">
                    <chose-menu ng-model="item.menu"></chose-menu>
                </div>
                <div class="controls" ng-show="chosedType == 3 ">
                    <resource chosemodel="item.permissions" name="permissions" callback="back(permissions)"></resource>
                    <table class="sui-table table-bordered mar-top" ng-show="item.permissions.length>0">
                        <thead>
                            <tr>
                                <th>{{'Module name'|translate}}</th>
                                <th>{{'path'|translate}}</th>
                                <th>{{'动作'|translate}}</th>
                                <th></th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr ng-repeat="(k,perm) in item.permissions">
                                <td>
                                    {{perm.name}}
                                </td>
                                <td>
                                    {{perm.identity}}
                                </td>
                                <td>
                                    {{perm.action}}
                                </td>
                                <td>
                                    <button type="button" ng-click="item.permissions.splice(k,1)" class="sui-btn btn-danger"> {{'delete' | translate}}</button>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                    <div class="role-1">
                        <button type="button" class="sui-btn btn-info" ng-click="AdditionalRole('jcinit')">+基础权限</button>
                        <button type="button" class="sui-btn btn-info" ng-click="AdditionalRole('kfinit')">+客服权限</button>
                        <!-- <button type="button" class="sui-btn btn-info" ng-click="AdditionalRole()">+类目权限</button> -->
                        <button type="button" class="sui-btn btn-info" ng-click="AdditionalRole('iteminit')">+商品权限</button>
                        <button type="button" class="sui-btn btn-info" ng-click="AdditionalRole('orderinit')">+订单权限</button>
                        <button type="button" class="sui-btn btn-info" ng-click="AdditionalRole('tixianinit')">+提现权限</button>
                        <button type="button" class="sui-btn btn-info" ng-click="AdditionalRole('chongzhiinit')">+充值权限</button>
                        <button type="button" class="sui-btn btn-info" ng-click="AdditionalRole('ordershinit')">+售后权限</button>
                        <button type="button" class="sui-btn btn-info" ng-click="AdditionalRole('hexiaoinit')">+核销权限</button>
                    </div>
                    <div class="role-1">
                        <button type="button" class="sui-btn btn-info" ng-click="AdditionalRole('dyinit')">+打印权限</button>
                        <button type="button" class="sui-btn btn-info" ng-click="AdditionalRole('zjdinit')">+发货点权限</button>
                        <button type="button" class="sui-btn btn-info" ng-click="AdditionalRole('mianfuinit')">+面付权限</button>
                        <button type="button" class="sui-btn btn-info" ng-click="AdditionalRole('dzinit')">+打折权限</button>
                        <button type="button" class="sui-btn btn-info" ng-click="AdditionalRole('msinit')">+满送权限</button>
                        <button type="button" class="sui-btn btn-info" ng-click="AdditionalRole('mzinit')">+满赠权限</button>
                        <button type="button" class="sui-btn btn-info" ng-click="AdditionalRole('jlinit')">+砍价权限</button>
                        <button type="button" class="sui-btn btn-info" ng-click="AdditionalRole('yfinit')">+邮费权限</button>
                    </div>
                    <div class="role-1">
                        <button type="button" class="sui-btn btn-info" ng-click="AdditionalRole('jqinit')">+微信卡券</button>
                        <button type="button" class="sui-btn btn-info" ng-click="AdditionalRole('ptinit')">+拼团权限</button>
                        <button type="button" class="sui-btn btn-info" ng-click="AdditionalRole('wmsinit')">+仓库权限</button>
                        <button type="button" class="sui-btn btn-info" ng-click="AdditionalRole('zdyinit')">+自定义表单权限</button>
                        <!-- <button type="button" class="sui-btn btn-info" ng-click="AdditionalRole('ptinit')">+分账权限</button> -->
                    </div>
                </div>
                <div class="controls" ng-show="chosedType == 4 ">
                    <!-- <a  href="#/role/fujia?role_id={{item.role_id}}" class="sui-btn btn-primary">{{'附加权限'|translate}}</a> -->
                    <fujia-resource chosemodel="permission_id_list" callback="fujiasaveresource(resoucres)"></fujia-resource>
                    <table class="sui-table table-bordered mar-top" ng-show="permission_list">
                        <thead>
                            <tr>
                                <th>{{'#'|translate}}</th>
                                <th>{{'动作'|translate}}</th>
                                <th></th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr ng-repeat="(k,perm) in permission_list">
                                <td style="width: 100px">
                                    {{k}}
                                </td>
                                <td style="width: 300px">
                                    <resource-one chosemodel="perm.pid"></resource-one>
                                </td>
                                <td>
                                    <button type="button" ng-click="permissionsSplice(perm.id,k)" class="sui-btn btn-danger"> {{'delete' | translate}}</button>
                                    <!-- <button type="button" ng-show="!perm.id" ng-click="permission_list.splice(k,1)" class="sui-btn btn-danger"> {{'delete' | translate}}</button> -->
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <div class="controls" ng-show="chosedType == 5">
                    <div ng-if="role_id">
                        <!-- <getuseropen backcall="addUserStore(open_id)"></getuseropen> -->
                        <role-user role-id="role_id" ng-model="user_wxstore" callback="addUserStoreList(users)"></role-user>
                    </div>
                    <div ng-if="role_id">
                        <table class="sui-table table-bordered">
                            <thead>
                                <tr>
                                    <th>#</th>
                                    <th>{{'头像'|translate}}</th>
                                    <th>{{'昵称'|translate}}</th>
                                    <th>{{'操作'|translate}}</th>
                                    <th></th>
                                </tr>
                            </thead>

                            <tbody>
                                <tr ng-repeat="list in user_wxstore track by list.user_id">
                                    <td>{{list.user_id}}</td>
                                    <td nowrap>
                                        <img ng-src="{{list.avatar}}" width="100px" height="100px"></td>
                                    <!-- <td>{{list.is_super_admin}}</td> -->
                                    <!-- <td>{{list.is_sys}}</td> -->
                                    <td>
                                        {{list.nick_name}}
                                    </td>
                                    <td nowrap>
                                        <wx-app-checkbox-alert ng-model="list.istores"></wx-app-checkbox-alert>
                                    </td>
                                    <td>
                                        <button type="button" class=" sui-btn btn-danger " ng-click="deleteUsers($index)">删除</button>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        <div class="control-group " ng-show="!item.is_super_admin ">
            <label class="control-label v-top "> {{'是否是发货商' | translate}} :</label>
            <div class="controls ">
                <postage ng-model="part_by_user "></postage>（没有发货地址，不需要选择.）
            </div>
        </div>
        <div class="control-group ">
            <label class="control-label "></label>
            <div class="controls ">
                <button type="submit " class="sui-btn btn-xlarge btn-primary " ng-disabled="!itemForm.$valid ">
                    <span>{{'save'|translate}}</span>
                </button>
            </div>
        </div>
    </form>
</div>